//  Created by wealthgrow on 2020/6/11.
//  Copyright © 2020 qimeng. All rights reserved.

#import "TPAPIConfig.h"

NSString* const PrdCompleteBaseUrl = @"https://www.zhishiyisheng.com";
NSString* const TPImgBaseUrl = @"https://i.zmylschool.com";

/**<域名. */
static NSString* const HostTest = @"https://it.zmylclould.com";
static NSString* const HostLocal_HW = @"http://177.19.88.53";
static NSString* const HostLocal_BCQ = @"http://177.19.88.73";
static NSString* const HostLocal_WCY = @"http://177.19.88.66";
static NSString* const HostLocal_MXC = @"http://177.19.88.69";

/**<端口号. */
static NSString* const Port_Test = @":19000";
static NSString* const Port_PreparePrd = @":19111";
static NSString* const PortLocal_Cheese = @":17193";
static NSString* const PortLocal_AIInquiry = @":17188";
static NSString* const PortLocal_Simulation = @":17145";
static NSString* const PortLocal_Anatomy = @":13000";
static NSString* const PortLocal_Megagame = @":17147";

/**<模块路径. */
static NSString* const UrlPath_Cheese = @"/doctor-cheese";
static NSString* const UrlPath_AIInquiry = @"/doctor-cheese-inquiry";
static NSString* const UrlPath_Simulation = @"/doctor-cheese-simulation";
static NSString* const UrlPath_Anatomy = @"/doctor-cheese-anatomy";
static NSString* const UrlPath_Megagame = @"/megagame-platform";

@implementation TPAPIConfig

///芝士医生模块
+ (NSString *)baseUrl {
    return [self urlForPort:PortLocal_Cheese path:UrlPath_Cheese];
}
///AI问诊模块
+ (NSString *)inquiryBaseUrl {
    return [self urlForPort:PortLocal_AIInquiry path:UrlPath_AIInquiry];
}
///虚拟仿真模块
+ (NSString *)simulationBaseUrl{
    return [self urlForPort:PortLocal_Simulation path:UrlPath_Simulation];
}
///解剖模块
+ (NSString *)anatomyBaseUrl {
    return [self urlForPort:PortLocal_Anatomy path:UrlPath_Anatomy];
}
///大赛模块
+ (NSString *)megagame_platformBaseUrl{
    return [self urlForPort:PortLocal_Megagame path:UrlPath_Megagame];
}

+ (NSString *)urlForPort:(NSString *)port path:(NSString *)path{
    ///区分：非自定义环境
    BOOL isCustomEnv = BaseUrlEnvPreparePrd;
    return [NSString stringWithFormat:@"%@%@%@", [self rootUrl], (isCustomEnv ? port : @""), path];
}

/// 通过这种字典映射的方式，代码将更加简洁且易于维护
+ (NSDictionary<NSNumber *, NSString *> *)environmentHostMap {
    static NSDictionary *map;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        map = @{
            @(BaseUrlEnvDev): [NSString stringWithFormat:@"%@%@", HostTest, Port_Test],
            @(BaseUrlEnvTest): [NSString stringWithFormat:@"%@%@", HostTest, Port_Test],
            @(BaseUrlEnvPreparePrd): [NSString stringWithFormat:@"%@%@", HostTest, Port_PreparePrd],
            @(BaseUrlEnvPrd): PrdCompleteBaseUrl,
            @(BaseUrlEnvBcq): HostLocal_BCQ,
            @(BaseUrlEnvHw): HostLocal_HW,
            @(BaseUrlEnvWCY): HostLocal_WCY,
            @(BaseUrlEnvMXC): HostLocal_MXC
        };
    });
    return map;
}

+ (NSString *)rootUrl {
    return PrdCompleteBaseUrl;
}

///非自定义环境
+ (NSString *)notCustomEnvironmentCompleteUrl {
    return PrdCompleteBaseUrl;
}

+ (NSString *)slideEnvironmentUrl {
    return [NSString stringWithFormat:@"%@/%@/", [self notCustomEnvironmentCompleteUrl], @"gviewer-mobile"];
}

+ (BOOL)shouldConsoleWith:(NSString *)urlStr {
    if ([urlStr containsString:@"h6/app/sendLogMsg"]) {
        return NO;
    }
    return YES;
}

+ (BOOL)shouldReportLogWith:(NSString *)urlStr {
    if ([urlStr containsString:@"h6/app/sendLogMsg"] ||
        [urlStr containsString:@"dc/event"]) {
        return NO;
    }
    return YES;
}

+ (BOOL)shouldReportLogRightNowWith:(NSString *)urlStr {
    if ([urlStr containsString:@"trade/api/tanpubeiOrderCreate"]) {
        return YES;
    }
    return NO;
}
@end
//#define TPAPIDevBcqPath @"bcq-debug"
//#define TPAPIDevHWPath @"hw-debug"
//#define TPAPIDevAnatomyPath @"jp-debug"
